<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
    function countDown(time) {
        var nowTime = +new Date();//返回的是当前时间总的毫秒数
        var inputTime = +new Date(time);//返回的是用户输入时间的总毫秒数
        var times = (inputTime - nowTime) / 1000; //time是剩余时间的总秒数
        var d = parseInt(times / 60 / 60 / 24);//时
        d = d < 10 ? '0' + d : d;
        var h = parseInt(times /60 / 60 % 24);//计算小时
        h = h < 10 ? '0' + h : h;
         var m = parseInt(times / 60 % 60);//计算分数
         m = m < 10 ? '0' + m : m;
         var s = parseInt(times % 60);//计算当前秒数
         s = s < 10 ? '0' + s : s;
         return d + '天' + h + '时' + m + '分' + s + '秒';
      }
      console.log(countDown('2020-12-27 23:00:00'));
      var date = new Date();
      console.log(date)
      </script>
</head>
<body>
    
</body>
</html>